export default {
    //  状态
    state: {
        count: 0,
    },

    getters: {
        doubleCount(state) {
            return state.count * 2
        }
    },

    // 同步操作
    mutations: {
        add(state) {
            state.count++;
        },

        decrease(state) {
            state.count--;
        }

    },

    // 异步操作
    actions: {
        delayAdd(context) {
            setTimeout(() => {
                context.commit('add');
            }, 2000)
        },

        delayDecrease(context) {
            setTimeout(() => {
                context.commit('decrease');
            }, 2000)
        }
    },

}
